<template>
	<view class="userPopupShow" v-if="userPopupShow">
		<view class="userPopupShow-mask" @click="closeUserPopup"></view>
		<view class="userPopupShow-c">
			<view class="userPopupShow-close" @click="closeUserPopup">
				<u-icon name="close" color="#909399" size="20"></u-icon>
			</view>
			<view class="search">
				<u-search placeholder="关键字进行筛选" :clearabled="true" :showAction="false"
					v-model="content"></u-search>
			</view>
			<scroll-view class="userPopupShow-c-list" scroll-y="true" @scrolltolower="scrolltolower">
				<view class="userPopupShow-c-list-item" v-for="(it,index) in list" @click="setUserCurrent(it)">
					<text>{{it.text || ''}}</text>
				</view>
				<u-loadmore :status="status" />
			</scroll-view>
			
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				userPopupShow: false,
				list: [],
				status: 'nomore',
				info: {},
				content: ''
			}
		},
		watch: {
			'content': {
				handler(val) {
					console.log('val', val)
					if(this.content === '') {
						this.list = this.info.text
					} else {
						this.list = this.info.text.filter(i=> i.text.indexOf(val) >= 0)
					}
					
				}
			}
		},
		methods:{
			closeUserPopup(){
				this.userPopupShow = false
			},
			scrolltolower(){
				console.log('触底了')
				if(this.isList) {
					this.params.page ++
					this.init()
				}
			},
			reload(){
				this.params.page = 1
				this.isList = true
				this.init()
			},
			init(){
			},
			show(e){
				this.userPopupShow = true
				this.info = e
				this.list = e.text
				this.content = ''
			},
			setUserCurrent(it){
				this.$emit('change',it.text)
				this.closeUserPopup()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.search {
		width: 100%;
		box-sizing: border-box;
		padding: 0 20rpx;
	}
	.userPopupShow {
		width: 100vw;
		height: 100vh;
		position: fixed;
		top: 0;
		right: 0;
		z-index: 999999;
		.userPopupShow-mask {
			width: 100%;
			height: 100%;
			background: rgba(0,0,0,0.2);
		}
		.userPopupShow-c {
			width: 600rpx;
			height: fit-content;
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			margin: auto;
			z-index: 2;
			background: white;
			border-radius: 30rpx;
			box-shadow: 0 0 12rpx #e4e4e4;
			.userPopupShow-close {
				display: flex;
				justify-content: flex-end;
				box-sizing: border-box;
				padding-right: 20rpx;
				padding-top: 20rpx;
			}
			.userPopupShow-c-list {
				width: 100%;
				padding: 20rpx;
				height: 620rpx;
				overflow-y: scroll;
				box-sizing: border-box;
				
			}
		}
		
	}
	.userPopupShow-c-list-item {
		width: 100%;
		display: flex;
		align-items: center;
		background: #F7F7F7;
		box-sizing: border-box;
		padding: 10rpx 20rpx;
		margin-bottom: 20rpx;
		border-radius: 10rpx;
		white-space: pre-wrap;
		
		
	}
	.spec-people {
		background: white;
		box-sizing: border-box;
		padding: 20rpx 33rpx 20rpx 30rpx;
		border-bottom: 10rpx solid #f5f5f5;
		align-items: center;
		.spec-address-r {
			width: 40rpx;
			display: flex;
			align-items: center;
			
			image {
				width: 40rpx;
				margin-right: 0;
			}
		}
	}
</style>